<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Class template linear_congruential_engine</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Chapter 1. Boost.Compute">
<link rel="up" href="../../boost_compute/reference.html#header.boost.compute.random.linear_congruential_engine_hpp" title="Header &lt;boost/compute/random/linear_congruential_engine.hpp&gt;">
<link rel="prev" href="discrete_distribution.html" title="Class template discrete_distribution">
<link rel="next" href="mersenne_twister_engine.html" title="Class template mersenne_twister_engine">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="discrete_distribution.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_compute/reference.html#header.boost.compute.random.linear_congruential_engine_hpp"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="mersenne_twister_engine.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.compute.linear_congruential_engine"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template linear_congruential_engine</span></h2>
<p>boost::compute::linear_congruential_engine — 'Quick and Dirty' linear congruential engine </p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../boost_compute/reference.html#header.boost.compute.random.linear_congruential_engine_hpp" title="Header &lt;boost/compute/random/linear_congruential_engine.hpp&gt;">boost/compute/random/linear_congruential_engine.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T <span class="special">=</span> <span class="identifier">uint_</span><span class="special">&gt;</span> 
<span class="keyword">class</span> <a class="link" href="linear_congruential_engine.html" title="Class template linear_congruential_engine">linear_congruential_engine</a> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// types</span>
  <span class="keyword">typedef</span> <span class="identifier">T</span> <a name="boost.compute.linear_congruential_engine.result_type"></a><span class="identifier">result_type</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="linear_congruential_engine.html#boost.compute.linear_congruential_engineconstruct-copy-destruct">construct/copy/destruct</a></span>
  <span class="keyword">explicit</span> <a class="link" href="linear_congruential_engine.html#idm10920-bb"><span class="identifier">linear_congruential_engine</span></a><span class="special">(</span><span class="identifier">command_queue</span> <span class="special">&amp;</span><span class="special">,</span> 
                                      <span class="identifier">result_type</span> <span class="special">=</span> <span class="identifier">default_seed</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="linear_congruential_engine.html#idm10929-bb"><span class="identifier">linear_congruential_engine</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="linear_congruential_engine.html" title="Class template linear_congruential_engine">linear_congruential_engine</a><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="linear_congruential_engine.html" title="Class template linear_congruential_engine">linear_congruential_engine</a><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;</span> <span class="special">&amp;</span> 
  <a class="link" href="linear_congruential_engine.html#idm10936-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="linear_congruential_engine.html" title="Class template linear_congruential_engine">linear_congruential_engine</a><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="linear_congruential_engine.html#idm10945-bb"><span class="special">~</span><span class="identifier">linear_congruential_engine</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="linear_congruential_engine.html#idm10859-bb">public member functions</a></span>
  <span class="keyword">void</span> <a class="link" href="linear_congruential_engine.html#idm10860-bb"><span class="identifier">seed</span></a><span class="special">(</span><span class="identifier">result_type</span><span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="linear_congruential_engine.html#idm10875-bb"><span class="identifier">seed</span></a><span class="special">(</span><span class="identifier">command_queue</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> OutputIterator<span class="special">&gt;</span> 
    <span class="keyword">void</span> <a class="link" href="linear_congruential_engine.html#idm10881-bb"><span class="identifier">generate</span></a><span class="special">(</span><span class="identifier">OutputIterator</span><span class="special">,</span> <span class="identifier">OutputIterator</span><span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> OutputIterator<span class="special">,</span> <span class="keyword">typename</span> Function<span class="special">&gt;</span> 
    <span class="keyword">void</span> <a class="link" href="linear_congruential_engine.html#idm10894-bb"><span class="identifier">generate</span></a><span class="special">(</span><span class="identifier">OutputIterator</span><span class="special">,</span> <span class="identifier">OutputIterator</span><span class="special">,</span> <span class="identifier">Function</span><span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="linear_congruential_engine.html#idm10912-bb"><span class="identifier">discard</span></a><span class="special">(</span><span class="identifier">size_t</span><span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// public data members</span>
  <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="identifier">default_seed</span><span class="special">;</span>
  <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="identifier">a</span><span class="special">;</span>
  <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">size_t</span> <span class="identifier">threads</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="idm35738"></a><h2>Description</h2>
<p>Quick and dirty linear congruential engine to generate low quality random numbers very quickly. For uses in which good quality of random numbers is required(Monte-Carlo Simulations), use other engines like Mersenne Twister instead. </p>
<div class="refsect2">
<a name="idm35741"></a><h3>
<a name="boost.compute.linear_congruential_engineconstruct-copy-destruct"></a><code class="computeroutput">linear_congruential_engine</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">explicit</span> <a name="idm10920-bb"></a><span class="identifier">linear_congruential_engine</span><span class="special">(</span><span class="identifier">command_queue</span> <span class="special">&amp;</span> queue<span class="special">,</span> 
                                    <span class="identifier">result_type</span> value <span class="special">=</span> <span class="identifier">default_seed</span><span class="special">)</span><span class="special">;</span></pre>Creates a new <code class="computeroutput"><a class="link" href="linear_congruential_engine.html" title="Class template linear_congruential_engine">linear_congruential_engine</a></code> and seeds it with <code class="computeroutput">value</code>. </li>
<li class="listitem">
<pre class="literallayout"><a name="idm10929-bb"></a><span class="identifier">linear_congruential_engine</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="linear_congruential_engine.html" title="Class template linear_congruential_engine">linear_congruential_engine</a><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;</span> <span class="special">&amp;</span> other<span class="special">)</span><span class="special">;</span></pre>Creates a new <code class="computeroutput"><a class="link" href="linear_congruential_engine.html" title="Class template linear_congruential_engine">linear_congruential_engine</a></code> object as a copy of <code class="computeroutput">other</code>. </li>
<li class="listitem">
<pre class="literallayout"><a class="link" href="linear_congruential_engine.html" title="Class template linear_congruential_engine">linear_congruential_engine</a><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;</span> <span class="special">&amp;</span> 
<a name="idm10936-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="linear_congruential_engine.html" title="Class template linear_congruential_engine">linear_congruential_engine</a><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;</span> <span class="special">&amp;</span> other<span class="special">)</span><span class="special">;</span></pre>Copies <code class="computeroutput">other</code> to <code class="computeroutput">*this</code>. </li>
<li class="listitem">
<pre class="literallayout"><a name="idm10945-bb"></a><span class="special">~</span><span class="identifier">linear_congruential_engine</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>Destroys the <code class="computeroutput"><a class="link" href="linear_congruential_engine.html" title="Class template linear_congruential_engine">linear_congruential_engine</a></code> object. </li>
</ol></div>
</div>
<div class="refsect2">
<a name="idm35814"></a><h3>
<a name="idm10859-bb"></a><code class="computeroutput">linear_congruential_engine</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idm10860-bb"></a><span class="identifier">seed</span><span class="special">(</span><span class="identifier">result_type</span> value<span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue<span class="special">)</span><span class="special">;</span></pre>
<p>Seeds the random number generator with <code class="computeroutput">value</code>.</p>
<p>
If no seed value is provided, <code class="computeroutput">default_seed</code> is used. </p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="computeroutput">queue</code></span></p></td>
<td><p>command queue to perform the operation</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">value</code></span></p></td>
<td><p>seed value for the random-number generator </p></td>
</tr>
</tbody>
</table></div></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idm10875-bb"></a><span class="identifier">seed</span><span class="special">(</span><span class="identifier">command_queue</span> <span class="special">&amp;</span> queue<span class="special">)</span><span class="special">;</span></pre>
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> OutputIterator<span class="special">&gt;</span> 
  <span class="keyword">void</span> <a name="idm10881-bb"></a><span class="identifier">generate</span><span class="special">(</span><span class="identifier">OutputIterator</span> first<span class="special">,</span> <span class="identifier">OutputIterator</span> last<span class="special">,</span> 
                <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue<span class="special">)</span><span class="special">;</span></pre>Generates random numbers and stores them to the range [<code class="computeroutput">first</code>, <code class="computeroutput">last</code>). </li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> OutputIterator<span class="special">,</span> <span class="keyword">typename</span> Function<span class="special">&gt;</span> 
  <span class="keyword">void</span> <a name="idm10894-bb"></a><span class="identifier">generate</span><span class="special">(</span><span class="identifier">OutputIterator</span> first<span class="special">,</span> <span class="identifier">OutputIterator</span> last<span class="special">,</span> <span class="identifier">Function</span> op<span class="special">,</span> 
                <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue<span class="special">)</span><span class="special">;</span></pre>
<p>Generates random numbers, transforms them with <code class="computeroutput">op</code>, and then stores them to the range [<code class="computeroutput">first</code>, <code class="computeroutput">last</code>). </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idm10912-bb"></a><span class="identifier">discard</span><span class="special">(</span><span class="identifier">size_t</span> z<span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue<span class="special">)</span><span class="special">;</span></pre>Generates <code class="computeroutput">z</code> random numbers and discards them. </li>
</ol></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2013, 2014 Kyle Lutz<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="discrete_distribution.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_compute/reference.html#header.boost.compute.random.linear_congruential_engine_hpp"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="mersenne_twister_engine.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
